<?php
/**
* PrayOnline Pastors Add new or Edit
* @author: trungdt
* @since: Jan 25, 2011
* @version: 1.0
* 
* Change logs
* Jan 25, 2011 - trungdt - first create
*/

if (!defined("EXPONENT")) exit("");
	$listing = null;
	if (isset($_GET['id'])) {
		$listing = $db->selectObject("pastors","id=".$_GET['id']);
		// this module dont use location_data
        //if ($listing != null) {
		//	$loc = unserialize($listing->location_data);
		//} 
	}
	
    // this module need administrator permission to manage subjects
	//if (exponent_permissions_check("manage",$loc)) {
    if (exponent_users_isAdmin() && exponent_users_isLoggedIn()){
		//$config = $db->selectObject('praymodule_config',"");
		//if ($config == null) {
		//	$config->item_per_page=10;
		//}
        $form = prayonline_subject::pastor_form($listing);
		//$form->location($loc);
		$form->meta("action","pastor_save");
        // because we dont set $loc, we must set module name
        $form->meta("module","praymodule");   
				
		$template = new template("praymodule","_pastor_form_edit",$loc);
		$template->assign("is_edit",(isset($listing->id) ? 1 : 0));
		$template->assign("form_html",$form->toHTML());
		$template->output();
	} else {
		echo SITE_403_HTML;
	}

?>
